package com.ai.exam.controller;
import com.ai.exam.model.RuleTitle;
import com.ai.exam.service.RuleTitleService;
import com.ai.exam.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* Created by CodeGenerator on 2018/06/01.
*/
@RestController
@RequestMapping("/rule")
public class RuleTitleController {
    @Resource
    private RuleTitleService ruleTitleService;

    @ApiOperation(value = "活动规则查询" ,notes = "返回结果")
    @GetMapping("/title")
    public Result addPrizeRecord() {
        List<RuleTitle> ruleTitles = ruleTitleService.selRule();
        return Result.success(ruleTitles);
    }

    @ApiOperation(value = "查询活动过期情况", notes = "返回结果")
    @GetMapping("/selOverdue")
    public Result selOverdue(){
        Map rs = ruleTitleService.isOverdue();
        if(!(boolean)rs.get("code")){
            return Result.fail((String) rs.get("msg"));
        }
        return Result.success(null);
    }
}
